home *** CD-ROM | disk | FTP | other *** search
Text File | 1988-11-20 | 2.7 KB | 79 lines | [TEXT/MPS ] |
-
- {=================== Global FieldToString Procedure ==================}
-
- { This procedure will allow your fields procedure to display all of }
- { the types defined by the SANE unit. The type constants are: }
- { bReal , bSingle - for Pascal Real and SANE Single type }
- { bDouble - for SANE Double type }
- { bExtended - for SANE Extended type }
- { }
- { Be sure to place the MyFieldToString routine in a RESIDENT Segment. }
- { (One that is never unloaded.) }
- { }
- { Also place the following line in your IApplication method: }
- { }
- { gFieldToStrRtn := @MyFieldToString; }
-
-
- {$IFC qDebug}
- {$IFC qTrace} {$D+} {$ENDC}
-
- PROCEDURE MyFieldToString(theData: Ptr;
- fieldType: integer;
- VAR theString: str255);
-
- CONSTANT
- DecPrec = 2; { Change this if you want more decimal precision }
-
- TYPE
- TAlias = RECORD
- CASE integer OF
- bReal, bSingle:
- (asReal : Real);
- bDouble:
- (asDouble : Double);
- bExtended:
- (asExtended : Extended);
- END;
-
- VAR
- alias : ^TAlias;
- aDecForm : DecForm;
- x : Extended;
- NumStr : DecStr;
-
- BEGIN
- alias := Pointer(theData);
- WITH alias^ DO
- CASE fieldType OF
- bReal, bSingle:
- BEGIN
- aDecForm.style := FixedDecimal;
- aDecForm.digits := DecPrec;
- x := asReal;
- Num2Str(aDecForm, x, NumStr);
- theString := str255(NumStr);
- END;
- bDouble:
- BEGIN
- aDecForm.style := FixedDecimal;
- aDecForm.digits := DecPrec;
- x := asDouble;
- Num2Str(aDecForm, x, NumStr);
- theString := str255(NumStr);
- END;
- bExtended:
- BEGIN
- aDecForm.style := FixedDecimal;
- aDecForm.digits := DecPrec;
- x := asExtended;
- Num2Str(aDecForm, x, NumStr);
- theString := str255(NumStr);
- END;
- OTHERWISE StdFieldToString(theData, fieldType, theString);
- END;
- END;
-
- {$IFC qTrace} {$D++} {$ENDC}
- {$ENDC qDebug}
-